<?php
/*
 * @Author: wanzhengxin
 * @Date: 2021-04-01 21:58:34
 */
namespace app\server\controller;

use app\index\controller\Base;//application统一的模式，不要修改
use app\server\model\ServerList as ServerListModel;  //引入model.
class Serverlist extends Base
{

    public function get(){
        $res = new ServerListModel();
        $data=$this->request->param();
        $a = $data['address'];
        $r=$res->hasWhere('organization', function($query) use ( $a){
                $query->where('address', 'like', '%'.$a.'%');
            })
            ->with("servers,organization")
            ->where($data['field'],$data['op'],$data['value'])
            ->order($data['order_by'],'desc')
            ->page($data['page'])
            ->limit(10)
            ->select();
        return $r;
    }
    public function getAll(){
        $res = new ServerListModel();
        $data=$this->request->param();
        $r=$res->where($data['field'],$data['op'],$data['value'])
            ->select();
        return $r;
    }
    public function update()
    {
        $data = $this->request->param();
        $res = new ServerListModel();
        return $res->updateModel($data);
    }
    public function delete(){
        $data = $this->request->param();
        $res = new ServerListModel();
        return $res->deleteModel($data);
    }
    public function save(){
        $res = new ServerListModel();
        $data = $this->request->param();
        $res->saveModel($data);
    }
    public function num(){
        $data = $this->request->param();
        $res =new ServerListModel();
        return $res->where($data['field'],$data['op'],$data['value'])->count();
    }

}